package com.ste.client;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.ObjectInputStream;
import java.util.logging.Logger;


public class ReadServer implements Runnable {
	private InputStream is;
	private View view;
	private static Logger log = Logger.getLogger(ReadServer.class.getName());
	public ReadServer(InputStream is, View view) {
		this.is = is;
		this.view = view;
	}

	@Override
	public void run() {
		BufferedReader ois = null;
		try {
			ois = new BufferedReader(new InputStreamReader(is));
			String mes = null;
			while (true) {
				mes = (String) ois.readLine();
				log.info("client in: " + mes);
				view.getCommandsHandler().processResponse(mes);
			}
		
		} catch (IOException e) {
		}finally{
			if (ois != null){
				try {
					ois.close();
				} catch (IOException e) {
				}
			}
		}
	}

}
